#include "findMisMatch.h"

void findMisMatch(char* read, char* ref, unsigned int* queryId, unsigned int *pos,unsigned int *offset,  struct Info  *mis)
{
	unsigned int readPos, refPos, readLength, numSA, i, k;
	unsigned char* misBase1 = mis->misBase1;
	unsigned char* misBase2 = mis->misBase2;
	unsigned char* misPos1 = mis->misPos1;
	unsigned char* misPos2 = mis->misPos2;
	unsigned char* numMismatch = mis->numMismatch;
	unsigned char misMatch;
	readLength = mis->readLength;
	numSA = mis->numSA;

	for(i = 0; i < numSA; i++)
	{
		readPos = readLength*(queryId[i]);
		for(k = 0, refPos=pos[offset[i]], misMatch = 0;  k < readLength; k++)
		{     
			if(read[readPos+k] != ref[refPos+k])
			{
				if(misMatch == 0)
				{
					misPos1[i] = k;
					misBase1[i] = read[readPos+k];
					
				}
				else if(misMatch == 1)
				{
					misPos2[i] = k;
					misBase2[i] = read[readPos+k];
				}
				misMatch++;
			}
		}
		numMismatch[i] = misMatch;
	}
}
